<script src="/js/lay-module/layui_exts/excel.js"/>
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <script type="text/html" id="auidtPartInfo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="pass"> 报名通过</button>
                <button class="layui-btn layui-btn-danger layui-btn-sm  data-delete-btn" lay-event="refuse"> 报名驳回
                </button>
                <button class="layui-btn layui-btn-success layui-btn-sm data-add-btn" lay-event="result-pass"> 成绩通过
                </button>
                <button class="layui-btn layui-btn-warm layui-btn-sm data-add-btn" lay-event="result-refuse"> 成绩驳回
                </button>

            </div>
        </script>
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">赛事</label>
                            <div class="layui-input-inline">
                                <select id="eventId" name="eventId" lay-filter="eventId"></select>
                            </div>
                            <label class="layui-form-label">组别</label>
                            <div class="layui-input-inline">
                                <select id="groupId" name="groupId">
                                </select>
                            </div>
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
                            </button>
                            <button type="button" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-export-btn"><i class="layui-icon layui-icon-export"></i> 导 出
                            </button>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">线上/线下</label>
                            <div class="layui-input-inline">
                                <select id="onlineSelect" name="onlineSelect">
                                </select>
                            </div>
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline">
                                <input type="text" id="name" name="name" class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="status0" title="待缴费" checked="">
                                <input type="checkbox" name="statusx2" title="报名取消" checked="">
                            </div>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="status1" title="报名待审核" checked="">
                                <input type="checkbox" name="status3" title="成绩待审核" checked="">
                            </div>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="status2" title="报名通过" checked="">
                                <input type="checkbox" name="status4" title="成绩通过" checked="">
                            </div>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="statusx1" title="报名驳回" checked="">
                                <input type="checkbox" name="statusx3" title="成绩驳回" checked="">
                            </div>

                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableId" lay-data="id:'currentTableId'">
        </table>


    </div>
</div>

<script>

    function focusBig(text) {
        layer.open({
            type: 1,
            title: '预览'
            , offset: 'auto' //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
            , id: 'layerDemoAuto' //防止重复弹出
            , content: '<div style="padding: 20px 100px;"><img  width="100%" height="100%" src=' + text + ' /> </div>'
            , btnAlign: 'c' //按钮居中
            , shade: 0 //不显示遮罩
            , yes: function () {
                layer.closeAll();
            }
        });
    }

    layui.use(['form', 'table', 'miniPage', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            miniPage = layui.miniPage;
        var status = [];
        var eventId = "";
        var groupId = "";
        var name = "";
        $.ajax({
            url: "/event/information/list",
            method: "post",
            contentType: "application/json",
            dataType: "json",
            success: function (res) {
                let event = [] = res.data;
                if (event.length !== 0) {
                    $("select[name=eventId]").empty();
                    for (let i = 0; i < event.length; i++) {
                        $("select[name=eventId]").append("<option value=" + event[i].id + ">" + event[i].name + "</option>")
                    }
                    status = [0, 1, 2, 3, 4, -1, -2, -3];
                    eventId = $("#eventId option:first").val();

                }
                $.ajax({
                    url: "/event/group/list?eventId=" + eventId,
                    method: "post",
                    contentType: "application/json",
                    dataType: "json",
                    success: function (res) {
                        let group = [] = res.data;
                        if (group.length !== 0) {
                            $("select[name=groupId]").empty();
                            $("select[name=groupId]").append('<option value="">全部</option>')
                            for (let i = 0; i < group.length; i++) {

                                $("select[name=groupId]").append("<option value=" + group[i].id + ">" + group[i].name + "</option>")
                            }
                        }
                        groupId = $("#groupId option:first").val();
                        form.render();
                    }
                })
                $("select[name=onlineSelect]").append('<option value="">全部</option>')
                $("select[name=onlineSelect]").append('<option value="1">线上</option>')
                $("select[name=onlineSelect]").append('<option value="0">线下</option>')
                onlineSelect = $("#onlineSelect option:first").val();
            }
        })


        setTimeout(function () {
            table.render({
                elem: '#currentTableId',
                url: '/participant/getAllParticipantData/by/eventId/status/page',
                method: "post",
                dataType: "json",
                contentType: "application/json",
                toolbar: '#auidtPartInfo',
                defaultToolbar: ['filter', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                page: true,
                cols: [[
                    {type: "checkbox", width: 50, fixed: true},
                    {field: 'groupName', title: '组别名称', minWidth: 150, sort: true, fixed: true},
                    {field: 'statusCode', title: '状态', minWidth: 150, sort: true, fixed: true},
                    {field: 'participantCode', title: '参赛码', minWidth: 150, edit: 'text'},
                    {field: 'online', title: '是否线上', minWidth: 150, sort: true,},
                    {field: 'wxNumber', title: '微信号', minWidth: 150},
                    {field: 'name', title: '姓名', minWidth: 150},
                    {field: 'reference', title: '邀请人', minWidth: 150},
                    // {field: 'province', title: '省', minWidth: 150},
                    // {field: 'city', title: '市', minWidth: 150},
                    // {field: 'area', title: '区县', minWidth: 150},
                    // {field: 'addr', title: '地址', minWidth: 150},
                    {field: 'eventsInRecentYear', title: '最近参加的赛事', minWidth: 150},
                    {field: 'bestResult', title: '最好成绩', minWidth: 150, sort: true},
                    {field: 'pic', title: '最好成绩截图', minWidth: 170, templet: imageboxPic},
                    {field: 'finalResult', title: '最终成绩', minWidth: 150},
                    {field: 'finalDistance', title: '最终距离', minWidth: 150},
                    {field: 'finalPIc', title: '最终成绩截图', minWidth: 170, templet: imageboxFinalPIc},
                    {field: 'sexCode', title: '性别'},
                    {field: 'nationality', title: '国籍'},
                    {field: 'nation', title: '民族'},
                    {field: 'documentTypeCode', title: '证件类型', minWidth: 150},
                    {field: 'documentNum', title: '证件号码', minWidth: 150},
                    {field: 'birthday', title: '生日', minWidth: 150},
                    {field: 'bloodType', title: '血型', minWidth: 150},
                    {field: 'country', title: '国家', minWidth: 150},
                    {field: 'trainingMileage', title: '训练里程', minWidth: 150},
                    {field: 'personalMobile', title: '个人手机', minWidth: 150},
                    {field: 'emergencyContactName', title: '紧急联系人', minWidth: 150},
                    {field: 'emergencyContactMobile', title: '紧急联系电话', minWidth: 150},
                    {field: 'clothingSize', title: '衣服尺寸', minWidth: 150},
                    {field: 'equipment', title: '设备', minWidth: 150},
                    {field: 'os', title: '系统', minWidth: 150},
                    {field: 'ip', title: 'ip', minWidth: 150},
                    {field: 'runTeamName', title: '跑团名称', minWidth: 150},
                    {field: 'amount', title: '金额', minWidth: 150},
                    {field: 'priceName', title: '套餐名称', minWidth: 150},
                    {field: 'teamName', title: '团队名称', minWidth: 150},
                    {field: 'passedPhysicalExamCode', title: '是否通过体检', minWidth: 150},
                    {field: 'browser', title: '浏览器', minWidth: 150},
                    {field: 'alunmiName', title: '校友会名称', minWidth: 150},
                    {field: 'alumniRelationPersion', title: '校友会联系人', minWidth: 150},
                    {field: 'email', title: '邮箱', minWidth: 150},
                    {field: 'education', title: '学历', minWidth: 150},
                    {field: 'occupation', title: '职业', minWidth: 150},
                    {field: 'companyName', title: '公司名称', minWidth: 150},
                    {field: 'companyPosition', title: '公司职务', minWidth: 150},


                ]],
                done: function (res, curr, count) {
                    let statusList = [];
                    let elementsByClassName = document.getElementsByClassName("layui-form-checked");
                    for (let i = 0; i < elementsByClassName.length; i++) {
                        let elementsByClassNameElement = elementsByClassName[i];
                        let innerText = elementsByClassNameElement.innerText;
                        if (innerText === '报名取消') {
                            statusList.push(-1)
                        }
                        if (innerText === '报名驳回') {
                            statusList.push(-2)
                        }
                        if (innerText === '成绩驳回') {
                            statusList.push(-3)
                        }
                        if (innerText === '待缴费') {
                            statusList.push(0)
                        }
                        if (innerText === '报名待审核') {
                            statusList.push(1)
                        }
                        if (innerText === '报名通过') {
                            statusList.push(2)
                        }
                        if (innerText === '成绩待审核') {
                            statusList.push(3)
                        }
                        if (innerText === '成绩通过') {
                            statusList.push(4)
                        }
                        eventId = $("#eventId").val(),
                            groupId = $("#groupId").val(),
                            name = $("#name").val(),
                            onlineSelect = $("#onlineSelect").val(),
                            status = statusList
                        this.where = {
                            "eventId": eventId,
                            "groupId": groupId,
                            "name": name,
                            "onlineSelect": onlineSelect,
                            "status": status
                        }

                    }

                }
                ,
                initSort: {
                    field: 'name' //排序字段，对应 cols 设定的各字段名
                    , type: 'desc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
                },
                limit: 10,
                skin: 'line',

                done: function (res, curr, count) {

                    let statusList = [];
                    let elementsByClassName = document.getElementsByClassName("layui-form-checked");
                    for (let i = 0; i < elementsByClassName.length; i++) {
                        let elementsByClassNameElement = elementsByClassName[i];
                        let innerText = elementsByClassNameElement.innerText;
                        if (innerText === '报名取消') {
                            statusList.push(-1)
                        }
                        if (innerText === '报名驳回') {
                            statusList.push(-2)
                        }
                        if (innerText === '成绩驳回') {
                            statusList.push(-3)
                        }
                        if (innerText === '待缴费') {
                            statusList.push(0)
                        }
                        if (innerText === '报名待审核') {
                            statusList.push(1)
                        }
                        if (innerText === '报名通过') {
                            statusList.push(2)
                        }
                        if (innerText === '成绩待审核') {
                            statusList.push(3)
                        }
                        if (innerText === '成绩通过') {
                            statusList.push(4)
                        }

                    }

                    eventId = $("#eventId").val(),
                        groupId = $("#groupId").val(),
                        name = $("#name").val(),
                        onlineSelect = $("#onlineSelect").val(),
                        status = statusList
                    this.where = {
                        "eventId": eventId,
                        "groupId": groupId,
                        "name": name,
                        "onlineSelect": onlineSelect,
                        "status": status
                    }
                },
            })
            //执行搜索重载
            table.reload('currentTableId', {
                request: {
                    pageName: 'page', //页码的参数名称，默认：page
                    limitName: 'limit', //每页数据量的参数名，默认：limit

                },
                where: {eventId: eventId, groupId: groupId, name: name, status: status, onlineSelect: onlineSelect},
                parseData: function (res) { //res 即为原始返回的数据
                    let list = []
                    if (undefined !== res.data) {
                        if (undefined!==res.data.list){
                            list = res.data.list;
                            list.forEach(d => {
                                if (d.status === 1) {
                                    d.statusCode = "<span>报名待审核</span>"
                                }
                                else if (d.status === 2) {
                                    d.statusCode = "<span>报名通过</span>"
                                }
                                else if (d.status === 3) {
                                    d.statusCode = "<span>成绩待审核</span>"
                                }
                                else if (d.status === 4) {
                                    d.statusCode = "<span>成绩通过</span>"
                                }
                                else if (d.status === -1) {
                                    d.statusCode = "<span>报名驳回</span>"
                                }
                                else if (d.status === -2) {
                                    d.statusCode = "<span>报名取消</span>"
                                }
                                else if (d.status === -3) {
                                    d.statusCode = "<span>成绩驳回</span>"
                                }
                                else if (d.status === 0) {
                                    d.statusCode = "<span>待缴费</span>"
                                }

                                if (d.sex === 1) {
                                    d.sexCode = "<span>男</span>"
                                } else {
                                    d.sexCode = "<span>女</span>"
                                }
                                if (d.passedPhysicalExam === 1) {
                                    d.passedPhysicalExamCode = "<span>通过</span>"
                                } else {
                                    d.passedPhysicalExamCode = "<span>未通过</span>"
                                }
                                if (d.documentType === 1) {
                                    d.documentTypeCode = "<span>身份证</span>"
                                } else if (d.documentType === 2) {
                                    d.documentTypeCode = "<span>港澳通行证</span>"
                                } else if (d.documentType === 3) {
                                    d.documentTypeCode = "<span>护照</span>"
                                }
                                if (d.online === 1) {
                                    d.online = "线上"
                                } else {
                                    d.online = "线下"
                                }
                            })
                        }
                    }

                    return {
                        "code": 0, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.count, //解析数据长度
                        "data": list //解析数据列表
                    };
                },
                done: function (res, curr, count) {
                    console.log(this.where)
                    let statusList = [];
                    let elementsByClassName = document.getElementsByClassName("layui-form-checked");
                    for (let i = 0; i < elementsByClassName.length; i++) {
                        let elementsByClassNameElement = elementsByClassName[i];
                        let innerText = elementsByClassNameElement.innerText;
                        if (innerText === '报名取消') {
                            statusList.push(-1)
                        }
                        if (innerText === '报名驳回') {
                            statusList.push(-2)
                        }
                        if (innerText === '成绩驳回') {
                            statusList.push(-3)
                        }
                        if (innerText === '待缴费') {
                            statusList.push(0)
                        }
                        if (innerText === '报名待审核') {
                            statusList.push(1)
                        }
                        if (innerText === '报名通过') {
                            statusList.push(2)
                        }
                        if (innerText === '成绩待审核') {
                            statusList.push(3)
                        }
                        if (innerText === '成绩通过') {
                            statusList.push(4)
                        }

                    }

                    eventId = $("#eventId").val(),
                        groupId = $("#groupId").val(),
                        name = $("#name").val(),
                        onlineSelect = $("#onlineSelect").val(),
                        status = statusList
                    this.where = {
                        "eventId": eventId,
                        "groupId": groupId,
                        "name": name,
                        "onlineSelect": onlineSelect,
                        "status": status
                    }
                },
            }, 'data');
        }, 1000)

        table.on('edit(currentTableId)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            $.ajax({
                url: "/participant/update/race/part/code?code=" + value + "&raceId=" + data.raceId,
                method: "post",
                contentType: "application/json",
                dataType: "json",
                success: function (res) {
                    if (res.status === 1) {
                        layer.alert(res.msg, {icon: 1});
                    } else {
                        layer.alert(res.msg, {icon: 2});
                    }
                    window.location.reload();
                }
            })
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {

            statusSearch = [];
            if (undefined !== data.field.status0) {
                statusSearch.push(0)
            }
            if (undefined !== data.field.status1) {
                statusSearch.push(1)
            }
            if (undefined !== data.field.status2) {
                statusSearch.push(2)
            }
            if (undefined !== data.field.status3) {
                statusSearch.push(3)
            }
            if (undefined !== data.field.status4) {
                statusSearch.push(4)
            }
            if (undefined !== data.field.statusx1) {
                statusSearch.push(-1)
            }
            if (undefined !== data.field.statusx2) {
                statusSearch.push(-2)
            }
            if (undefined !== data.field.statusx3) {
                statusSearch.push(-3)
            }
            if (0 === statusSearch.length) {
                layer.alert("状态至少选一个", {icon: 2})
                return false;
            }

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                ,
                where: {
                    eventId: $("#eventId").val(),
                    groupId: $("#groupId").val(),
                    name: $("#name").val(),
                    onlineSelect: $("#onlineSelect").val(),
                    status: statusSearch
                },
            }, 'data');
            return false;
        });
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


        form.on('select(eventId)', function () {

            $.ajax({
                url: "/event/group/list?eventId=" + $("select[name=eventId]").val(),
                method: "post",
                contentType: "application/json",
                dataType: "json",
                success: function (res) {
                    let group = [] = res.data;
                    if (group.length !== 0) {
                        $("select[name=groupId]").empty();
                        $("select[name=groupId]").append('<option value="">全部</option>')
                        for (let i = 0; i < group.length; i++) {
                            $("select[name=groupId]").append("<option value=" + group[i].id + ">" + group[i].name + "</option>")
                        }
                    }
                    form.render();
                }
            })
        })

        form.on('submit(data-export-btn)', function (data) {
            statusSearch = [];
            if (undefined !== data.field.status0) {
                statusSearch.push(0)
            }
            if (undefined !== data.field.status1) {
                statusSearch.push(1)
            }
            if (undefined !== data.field.status2) {
                statusSearch.push(2)
            }
            if (undefined !== data.field.status3) {
                statusSearch.push(3)
            }
            if (undefined !== data.field.status4) {
                statusSearch.push(4)
            }
            if (undefined !== data.field.statusx1) {
                statusSearch.push(-1)
            }
            if (undefined !== data.field.statusx2) {
                statusSearch.push(-2)
            }
            if (undefined !== data.field.statusx3) {
                statusSearch.push(-3)
            }
            if (0 === statusSearch.length) {
                layer.alert("状态至少选一个", {icon: 2})
                return false;
            }

            $.ajax({
                url: '/participant/getAllParticipantData/by/eventId/status/page',
                method: "post",
                dataType: "json",
                contentType: "application/json",
                data: JSON.stringify({
                    eventId: $("#eventId").val(),
                    groupId: $("#groupId").val(),
                    onlineSelect: $("#onlineSelect").val(),
                    name: $("#name").val(),
                    status: statusSearch,
                    curr: 1,
                    limit: 10000000
                }),
                success: function (result) {
                    let list = [] = result.data.list;
                    let excel = layui.excel;
                    list.forEach(d => {
                        if (d.status === 1) {
                            d.statusCode = "报名待审核"
                        }
                        else if (d.status === 2) {
                            d.statusCode = "报名通过"
                        }
                        else if (d.status === 3) {
                            d.statusCode = "成绩待审核"
                        }
                        else if (d.status === 4) {
                            d.statusCode = "成绩通过"
                        }
                        else if (d.status === -1) {
                            d.statusCode = "报名驳回"
                        }
                        else if (d.status === -2) {
                            d.statusCode = "报名取消"
                        }
                        else if (d.status === -3) {
                            d.statusCode = "成绩驳回"
                        }
                        else if (d.status === 0) {
                            d.statusCode = "待缴费"
                        }

                        if (d.sex === 1) {
                            d.sexCode = "男"
                        } else {
                            d.sexCode = "女"
                        }
                        if (d.passedPhysicalExam === 1) {
                            d.passedPhysicalExamCode = "通过"
                        } else {
                            d.passedPhysicalExamCode = "未通过"
                        }
                        if (d.documentType === 1) {
                            d.documentTypeCode = "身份证"
                        } else if (d.documentType === 2) {
                            d.documentTypeCode = "港澳通行证"
                        } else if (d.documentType === 3) {
                            d.documentTypeCode = "护照"
                        }
                        if (d.pic !== undefined && d.pic !== "" && d.pic !== null) {
                            d.pic = d.pic.substring(0, d.pic.length - 1)
                        }
                    })
                    list = excel.filterExportData(list, [
                        'groupName'
                        , 'statusCode'
                        , 'participantCode'
                        , 'online'
                        , 'reference'
                        , 'wxNumber'
                        , 'name'
                        , 'eventsInRecentYear'
                        , 'bestResult'
                        , 'pic'
                        , 'finalResult'
                        , 'finalDistance'
                        , 'finalPIc'
                        , 'sexCode'
                        , 'nationality'
                        , 'nation'
                        , 'documentTypeCode'
                        , 'documentNum'
                        , 'birthday'
                        , 'bloodType'
                        // , 'country'
                        // , 'province'
                        // , 'city'
                        // , 'area'
                        // , 'addr'
                        , 'trainingMileage'
                        , 'personalMobile'
                        , 'emergencyContactName'
                        , 'emergencyContactMobile'
                        , 'clothingSize'
                        , 'equipment'
                        , 'os'
                        , 'browser'
                        , 'ip'
                        , 'amount'
                        , 'priceName'
                        , 'alunmiName'
                        , 'alumniRelationPersion'
                        , 'teamName'
                        , 'passedPhysicalExamCode'
                        , 'email'
                        , 'education'
                        , 'occupation'
                        , 'companyName'
                        , 'companyPosition'

                    ]);
                    // 重点2！！！一般都需要加一个表头，表头的键名顺序需要与最终导出的数据一致
                    list.unshift({
                        groupName: '组别名称'
                        , statusCode: '状态'
                        , participantCode: '参赛码'
                        , online: '线上线下'
                        , reference: '邀请人'
                        , wxNumber: '微信号'
                        , name: '姓名'
                        , eventsInRecentYear: '最近参加的赛事'
                        , bestResult: '最好成绩'
                        , pic: '最好成绩截图'
                        , finalResult: '最终成绩'
                        , finalDistance: '最终距离'
                        , finalPIc: '最终成绩截图'
                        , sexCode: '性别'
                        , nationality: '国籍'
                        , nation: '民族'
                        , documentTypeCode: '证件类型'
                        , documentNum: '证件号码'
                        , birthday: '生日'
                        , bloodType: '血型'
                        // , country: '国家'
                        // , province: '省'
                        // , city: '市'
                        // , area: '区县'
                        // , addr: '地址'
                        , trainingMileage: '训练里程'
                        , personalMobile: '个人手机'
                        , emergencyContactName: '紧急联系人'
                        , emergencyContactMobile: '紧急联系电话'
                        , clothingSize: '衣服尺寸'
                        , equipment: '设备'
                        , os: '系统'
                        , browser: '浏览器'
                        , ip: 'ip'
                        , amount: '金额'
                        , priceName: '套餐名称'
                        , alunmiName: '校友会名称'
                        , alumniRelationPersion: '校友会联系人'
                        , teamName: '团队名称'
                        , passedPhysicalExamCode: '是否通过体检'
                        , email: '邮箱'
                        , education: '学历'
                        , occupation: '职业'
                        , companyName: '公司名称'
                        , companyPosition: '公司职务'
                    });

                    var timestart = Date.now();
                    excel.exportExcel(list, '参赛报名记录--' + timestart + '.xlsx', 'xlsx');
                }
            })
        })


        /**
         * toolbar事件监听
         */
        table.on('toolbar(currentTableId)', function (obj) {
            var checkStatus = table.checkStatus('currentTableId')
                , data = checkStatus.data;
            if (obj.event === 'pass') {   // 监听添加操作
                let dataList = data;
                let count = 0;
                for (let i = 0; i < dataList.length; i++) {
                    let d = dataList[i];
                    let raceId = d.raceId;
                    let pibId = d.pibId;
                    $.ajax({
                        url: '/participant/pass?infoId=' + pibId + '&raceId=' + raceId,
                        method: "post",
                        async: false,
                        contentType: "application/json",
                        success: function (res) {
                            if (res.status === 1) {
                                count++;
                            }
                        }
                    })
                }
                if (count < dataList.length) {
                    layer.alert("有" + (dataList.length - count) + "个数据操作失败，该状态下不允许修改状态", {icon: 2});
                } else {
                    layer.alert("成功", {icon: 1});
                }
                window.location.reload();

            } else if (obj.event === 'result-pass') {
                let dataList = data;
                let count = 0;
                for (let i = 0; i < dataList.length; i++) {
                    let d = dataList[i];
                    let raceId = d.raceId;
                    let pibId = d.pibId;
                    $.ajax({
                        url: '/result/pass?infoId=' + pibId + '&raceId=' + raceId,
                        method: "post",
                        dataType: "json",
                        async: false,
                        contentType: "application/json",
                        data: JSON.stringify({
                            raceId: raceId,
                            pibId: pibId
                        }),
                        success: function (res) {
                            if (res.status === 1) {
                                count++;
                            }
                        }
                    })
                }
                if (count < dataList.length) {
                    layer.alert("有" + (dataList.length - count) + "个数据操作失败，该状态下不允许修改状态", {icon: 2});
                } else {
                    layer.alert("成功", {icon: 1});
                }
                window.location.reload();
            }


            else if (obj.event === 'refuse') {  // 监听删除操作
                let dataList = data;
                let count = 0;
                for (let i = 0; i < dataList.length; i++) {
                    let d = dataList[i];
                    let raceId = d.raceId;
                    let pibId = d.pibId;
                    $.ajax({
                        url: '/participant/refuse?infoId=' + pibId + '&raceId=' + raceId,
                        method: "post",
                        dataType: "json",
                        async: false,
                        contentType: "application/json",
                        data: JSON.stringify({
                            raceId: raceId,
                            pibId: pibId
                        }),
                        success: function (res) {
                            if (res.status === 1) {
                                count++;
                            }
                        }
                    })
                }
                if (count < dataList.length) {
                    layer.alert("有" + (dataList.length - count) + "个数据操作失败，该状态下不允许修改状态", {icon: 2});
                } else {
                    layer.alert("成功", {icon: 1});
                }
                window.location.reload();
            } else if (obj.event === 'result-refuse') {
                let dataList = data;
                let count = 0;
                for (let i = 0; i < dataList.length; i++) {
                    let d = dataList[i];
                    let raceId = d.raceId;
                    let pibId = d.pibId;
                    $.ajax({
                        url: '/result/refuse?infoId=' + pibId + '&raceId=' + raceId,
                        method: "post",
                        dataType: "json",
                        async: false,
                        contentType: "application/json",
                        data: JSON.stringify({
                            raceId: raceId,
                            pibId: pibId
                        }),
                        success: function (res) {
                            if (res.status === 1) {
                                count++;
                            }
                        }
                    })
                }
                if (count < dataList.length) {
                    layer.alert("有" + (dataList.length - count) + "个数据操作失败，该状态下不允许修改状态", {icon: 2});
                } else {
                    layer.alert("成功", {icon: 1});
                }
                window.location.reload();
            }
        });

        function imageboxPic(data) {
            if (data.pic != null && data.pic != '' && data.pic != undefined) {
                let picList = data.pic.split(',');
                var img = '';
                for (let i = 0; i < picList.length; i++) {
                    img +=
                        '<div onclick=focusBig(' + "'" + picList[i] + "'" + ') style="display: inline-block">' +
                        "<img src='" + picList[i] + "' alt='Alternate Text' style='width:40px;height:40px;'/>" +
                        "</div>";
                }
                return img;
            } else {
                return '';
            }
        }

        function imageboxFinalPIc(data) {
            if (data.finalPIc != null && data.finalPIc !== '' && data.finalPIc !== undefined) {
                let picList = data.finalPIc.split(',');
                var img = '';
                for (let i = 0; i < picList.length; i++) {
                    img +=
                        '<div onclick=focusBig(' + "'" + picList[i] + "'" + ') style="display: inline-block">' +
                        "<img src='" + picList[i] + "' alt='Alternate Text' style='width:40px;height:40px;'/>" +
                        "</div>";
                }
                return img;
            } else {
                return "";
            }
        }


    });
</script>